import React, { Component } from 'react'
import Header from '../../components/Header/Header'
import qs from "qs"
import { NavLink } from 'react-router-dom'


export default class List extends Component {
    constructor(){
        super()
        this.state={
            goods:[
                {
                    id:1,catename:"手机"
                },  
                {
                    id:2,catename:"手2"
                },
            ]
        }
    }
    componentDidMount(){
        console.log(this.props);           //裁掉？号
        let search =this.props.location.search.slice(1)//"?id=2&a=1&b=2" "id=2&a=1&b=2"
        //1 path 'src/http/aoi.js'
        // 取url带来的参数
        let result =qs.parse(search)
        console.log(result);

    }
    render() {
        let {goods}=this.state
        return (
            <div>
                <Header title="商品列表" back></Header>
                {/* 详情 */}
                {goods.map(item=>(
                <div key={item.id}><NavLink to={"/detail/"+item.id+'/'+item.catename}>{item.catename}</NavLink></div>))}
            </div>
        )
    }
}
